package com.beasts.ant.auth.repository;

import com.beasts.ant.auth.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author Locker
 * @date 13/05/2018 9:39 AM
 * @since 1.0
 */
public interface UserRepository extends JpaRepository<User, String> {

    /**
     * 用户名查询用户，忽略大小写
     *
     * @param username
     * @return {@link User}
     */
    @Query("select u from User u where lower(u.username) = lower(:username) ")
    User findByUsernameCaseInsensitive(@Param("username") String username);

}
